//
//  ViewController.m
//  5-24学习
//
//  Created by 钟纪旺 on 16/5/24.
//  Copyright © 2016年 zjw. All rights reserved.
//

#import "ViewController.h"
#import "TwoViewController.h"
#import "ThreeViewController.h"
#import "OneViewController.h"
@interface ViewController (){

    NSArray *Data;


}

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    Data = @[@"联系人",
             @"日历",
             @"苹果1512通讯录"
             
             ];
    // Do any additional setup after loading the view, typically from a nib.
    self.navigationController.title = @"我的导航";
   // self.view.backgroundColor = [UIColor redColor];
    self.view.backgroundColor = [UIColor orangeColor];
    //添加刷新工具
    self.refreshControl = [UIRefreshControl new];
    //刷新工具图标增加颜色
    self.refreshControl.tintColor =[UIColor blueColor];
    self.refreshControl.attributedTitle = [[NSAttributedString alloc]initWithString:@"正在刷新" attributes:@{NSForegroundColorAttributeName:[UIColor blueColor]}];
    //设置文字控制停止器 结束刷新
    self.navigationItem.rightBarButtonItem =[[UIBarButtonItem alloc]initWithTitle:@"🔘" style:UIBarButtonItemStylePlain target:self action:@selector(onClick:)];
    //使用系统图标控制停止器 结束刷新
    //UIBarButtonSystemItem系统图标
   // self.navigationItem.rightBarButtonItem =[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemStop target:self action:@selector(onClick:)];
    //使用自己的图标设置控制停止器
    //self.navigationItem.rightBarButtonItem =[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"2"] style:UIBarButtonItemStylePlain target:self action:@selector(onClick:)];
    //使用自己的图设置导航栏
    UIImageView *iv =[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"3"]];
    self.navigationItem.titleView = iv;
    
}
- (void)onClick:(id)sender{

    [self.refreshControl endRefreshing];




}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{



    return Data.count;



}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell =[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:nil];
   // cell.textLabel.text = @"联系人";
    //找自己图片
    NSString *imgName =[NSString stringWithFormat:@"%ld",indexPath.row + 1];
    cell.imageView.image =[UIImage imageNamed:imgName];
    //图片切圆
    cell.imageView.layer.cornerRadius = 18;
    cell.imageView.clipsToBounds = YES;
    
    cell.textLabel.text =Data [indexPath.row];
    //给cell加颜色
   // cell.backgroundColor =[UIColor colorWithRed:20*indexPath.row/555.0 green:40*indexPath.row/3300.0 blue:60*indexPath.row/255.0 alpha:1];
    //给cell加箭头
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    return cell;

}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row ==0 ) {
        TwoViewController *con = [TwoViewController new];
        [self.navigationController pushViewController:con animated:YES];
    
    }if (indexPath.row ==1) {
        ThreeViewController *abc =[ThreeViewController new];
        [self.navigationController pushViewController:abc animated:YES];
   }
        if (indexPath.row ==2) {
        OneViewController *a =[OneViewController new];
        [self.navigationController pushViewController:a animated:YES];
    }
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
